package com.ruoyi.web.operate.feedback.approval.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.operate.feedback.approval.mapper.FeedBackApprovalMapper;
import com.ruoyi.web.operate.feedback.approval.domain.FeedBackApproval;
import com.ruoyi.web.operate.feedback.approval.service.IFeedBackApprovalService;

/**
 * 反馈审核Service业务层处理
 *
 * @author houxuzhong
 * @date 2021-08-26
 */
@Service
public class FeedBackApprovalServiceImpl implements IFeedBackApprovalService
{
    @Autowired
    private FeedBackApprovalMapper feedBackApprovalMapper;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询反馈审核
     *
     * @param id 反馈审核主键
     * @return 反馈审核
     */
    @Override
    public FeedBackApproval selectFeedBackApprovalById(Long id)
    {
        return feedBackApprovalMapper.selectFeedBackApprovalById(id);
    }

    /**
     * 查询反馈审核列表
     *
     * @param feedBackApproval 反馈审核
     * @return 反馈审核
     */
    @Override
    public List<FeedBackApproval> selectFeedBackApprovalList(FeedBackApproval feedBackApproval)
    {
        return feedBackApprovalMapper.selectFeedBackApprovalList(feedBackApproval);
    }

    /**
     * 查询反馈审核列表
     *
     * @param feedBackApproval 反馈审核
     * @return 反馈审核
     */
    @Override
    public List<FeedBackApproval> selectMyFeedBackList(FeedBackApproval feedBackApproval)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        SysUser user = loginUser.getUser();
        feedBackApproval.setStockOwnerid(user.getUserId());
        return feedBackApprovalMapper.selectMyFeedBackList(feedBackApproval);
    }

    /**
     * 新增反馈审核
     *
     * @param feedBackApproval 反馈审核
     * @return 结果
     */
    @Override
    public int insertFeedBackApproval(FeedBackApproval feedBackApproval)
    {
        feedBackApproval.setCreateTime(DateUtils.getNowDate());
        return feedBackApprovalMapper.insertFeedBackApproval(feedBackApproval);
    }

    /**
     * 修改反馈审核
     *
     * @param feedBackApproval 反馈审核
     * @return 结果
     */
    @Override
    public int updateFeedBackApproval(FeedBackApproval feedBackApproval)
    {
        feedBackApproval.setUpdateTime(DateUtils.getNowDate());
        return feedBackApprovalMapper.updateFeedBackApproval(feedBackApproval);
    }

    /**
     * 批量删除反馈审核
     *
     * @param ids 需要删除的反馈审核主键
     * @return 结果
     */
    @Override
    public int deleteFeedBackApprovalByIds(Long[] ids)
    {
        return feedBackApprovalMapper.deleteFeedBackApprovalByIds(ids);
    }

    /**
     * 删除反馈审核信息
     *
     * @param id 反馈审核主键
     * @return 结果
     */
    @Override
    public int deleteFeedBackApprovalById(Long id)
    {
        return feedBackApprovalMapper.deleteFeedBackApprovalById(id);
    }
}
